package com.apes.hr.salary.rewardPunish.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.hr.salary.rewardPunish.model.TeamRewardPunishDistribution;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author linwz
 * @create 2019-02-27 09:47
 */
public interface TeamRewardPunishDistributionRepository extends CustomRepository<TeamRewardPunishDistribution, Long>{

    @Modifying
    @Query(value = "DELETE FROM HR_REWARD_PUNISH_DISTRIBUTION T WHERE T.TEAM_REWARD_PUNISH_PRE_ID IN (SELECT T.ID FROM HR_TEAM_REWARD_PUNISH_PRE T WHERE T.TEAM_REWARD_PUNISH_ID = :id AND T.STATE != 'approve')",nativeQuery = true)
    int deleteByTeamRewardPunishId(@Param("id") String id);
}
